/**
 * @param {number[]} nums
 * @return {number}
 */
//数组都排序好了
var removeDuplicates = function (nums) {
    let index = 1; //从第二个元素开始  指向提取后的位置
    for (let i = 0; i < nums.length; i++) {
        if (nums[i] !== nums[i + 1]) {  //如果前后不相等
            nums[index++] = nums[i + 1];  //
        }
    }
    return index - 1
};


let nums = [0,0,1,1,1,2,2,3,3,4]
removeDuplicates(nums);
console.log(nums);